<?php

/*
|--------------------------------------------------------------------------
| API 路由定义
|--------------------------------------------------------------------------
|
| 在这里定义API路由，为了方便阅读，建议使用apiResource定义资源路由组，并对一类
| 业务路由进行分组管理！
|
*/

/**
 * 用户注册认证路由组
 */
Route::group(['prefix' => 'auth', 'namespace' => 'Auth'], function () {
	Route::post('login', 'LoginController@login');
	Route::post('logout', 'LoginController@logout')->middleware('auth:user');
	Route::post('register', 'RegisterController@register');
	Route::post('registerable', 'RegisterController@registerable');
});

/**
 * 系统公用服务
 */
Route::group(['prefix' => 'common', 'namespace' => 'Common'], function () {
	Route::get('companies', 'PublicController@companies');
	Route::post('sendCode', 'MessageController@sendCode');
	Route::get('getCompany','ConditionController@getCompany');
    Route::get('getProject','ConditionController@getProject');
    Route::get('modules','PublicController@modules');
});

/**
 * 用户账户
 */
Route::group(['prefix' => 'account', 'namespace' => 'Account', 'middleware' => 'auth:user,admin'], function () {
	Route::get('personal', 'PersonalController@profile');
	Route::post('modify/avatar', 'PersonalController@modifyAvatar');
	Route::post('modify/password', 'PersonalController@modifyPassword');
	Route::post('modify/personal', 'PersonalController@modifyProfile');
	Route::post('modify/identification', 'PersonalController@modifyIdentification');
	Route::get('schedule', 'PersonalController@schedule');
	Route::post('signin', 'PersonalController@signin');
	Route::post('joinCompany', 'PersonalController@joinCompany');
	Route::post('inspection', 'PersonalController@inspection');
	Route::post('station', 'PersonalController@station');
});

/**
 * 管理员账户
 */
Route::group(['middleware' => 'auth:user,admin'], function () {
	Route::apiResource('company', 'CompanyController');
	Route::get('company/{company}/modules', 'CompanyController@modules');
	Route::post('company/{company}/syncModules', 'CompanyController@syncModules');
	Route::post('company/batch/vetting', 'CompanyController@batchVetting');
	Route::patch('company/{company}/vetting', 'CompanyController@vetting');
	Route::apiResource('department', 'DepartmentController');
	Route::apiResource('position', 'PositionController');
	Route::apiResource('banner', 'BannerController');
	Route::post('banner/upload', 'BannerController@upload');
	Route::apiResource('project', 'ProjectController');
	Route::apiResource('user', 'UserController');
	Route::apiResource('article', 'ArticlesController');
    Route::post('article/upload', 'ArticlesController@upload');
    Route::get('attendance/report', 'AttendanceController@report');
    Route::apiResource('attendance', 'AttendanceController');
	Route::apiResource('genre', 'GenreController');
	Route::apiResource('schedule', 'ScheduleController');
	Route::put('consociation/updates','ConsociationController@updates');
    Route::get('consociation/company','ConsociationController@company');
    Route::apiResource('consociation','ConsociationController');
    Route::post('conference/{conference}/upload','ConferenceController@upload');
    Route::apiResource('conference','ConferenceController');
    Route::apiResource('demand', 'DemandController');
    Route::apiResource('regsetting', 'RegsettingsController');
    Route::apiResource('announcement', 'AnnouncementController');
	Route::get('inspection/report', 'InspectionController@report');
    Route::apiResource('inspection', 'InspectionController');
    /**
     * 巡检管理路由
     */
    Route::group(['namespace' => 'Inspection'], function () {
        Route::apiResource('line', 'LineController');
        Route::apiResource('circle', 'CircleController');
        Route::apiResource('node', 'NodeController');
    });
	/**
	 * 报岗岗位
	 */
    Route::post('station/schedule', 'StationController@schedule');
    Route::get('station/summary', 'ReportController@summary');
    Route::apiResource('station', 'StationController');
});
/**
 * 系统
 */
Route::group(['prefix' => 'system', 'namespace' => 'System', 'middleware' => 'auth:user,admin'], function () {
	Route::apiResource('module', 'ModuleController');
	Route::apiResource('position', 'PositionController');
	Route::apiResource('permission', 'PermissionController');
	Route::post('/upload', 'UploadController@upload');
	Route::get('setting', 'SettingController@index');
});

Route::get('test', function () {
	return $project = \App\Models\Project::withCount('settings')->where('id', 1)->first();
});
